﻿using System;
using System.Runtime.InteropServices;

namespace ShellLib
{
    public struct SHFILEINFO
{
    public IntPtr hIcon;
    public IntPtr iIcon;
    public uint dwAttributes;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
    public string szDisplayName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
    public string szTypeName;


    /// <summary>
    /// Contains parameters for the SHBrowseForFolder function and receives information about the folder selected 
    /// by the user.
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct BROWSEINFO
    {
        public IntPtr hwndOwner;				// Handle to the owner window for the dialog box.

        public IntPtr pidlRoot;					// Pointer to an item identifier list (PIDL) specifying the 
        // location of the root folder from which to start browsing.

        [MarshalAs(UnmanagedType.LPStr)]		// Address of a buffer to receive the display name of the 
        public String pszDisplayName;			// folder selected by the user.

        [MarshalAs(UnmanagedType.LPStr)]		// Address of a null-terminated string that is displayed 
        public String lpszTitle;				// above the tree view control in the dialog box.

        public UInt32 ulFlags;					// Flags specifying the options for the dialog box. 

        [MarshalAs(UnmanagedType.FunctionPtr)]	// Address of an application-defined function that the 
        public Imports.BrowseCallbackProc lpfn;			// dialog box calls when an event occurs.

        public Int32 lParam;					// Application-defined value that the dialog box passes to 
        // the callback function

        public Int32 iImage;					// Variable to receive the image associated with the selected folder.
    }

    [StructLayout(LayoutKind.Explicit)]
    public struct STRRET
    {
        /// <summary>
        /// One of the STRRET_* values
        /// </summary>
        [FieldOffset(0)]
        public UInt32 uType;

        /// <summary>
        /// must be freed by caller of GetDisplayNameOf
        /// </summary>
        [FieldOffset(4)]
        public IntPtr pOleStr;

        /// <summary>
        /// NOT USED
        /// </summary>
        [FieldOffset(4)]
        public IntPtr pStr;

        /// <summary>
        /// Offset into SHITEMID
        /// </summary>
        [FieldOffset(4)]
        public UInt32 uOffset;

        /// <summary>
        /// Buffer to fill in (ANSI)
        /// </summary>
        [FieldOffset(4)]
        public IntPtr cStr;
    }

    /// <summary>
    /// Contains information used by ShellExecuteEx
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct SHELLEXECUTEINFO
    {
        /// <summary>
        /// Size of the structure, in bytes.
        /// </summary>
        public UInt32 cbSize;

        /// <summary>
        /// Array of flags that indicate the content and validity of the other structure members.
        /// </summary>
        public UInt32 fMask;
        /// <summary>
        /// Window handle to any message boxes that the system might produce while executing this function. 
        /// </summary>
        public IntPtr hwnd;
        /// <summary>
        /// String, referred to as a verb, that specifies the action to be performed. 
        /// </summary>
        [MarshalAs(UnmanagedType.LPWStr)]
        public String lpVerb;

        /// <summary>
        /// Address of a null-terminated string that specifies the name of the file or object on
        ///  which ShellExecuteEx will perform the action specified by the lpVerb parameter.
        /// </summary>
        [MarshalAs(UnmanagedType.LPWStr)]
        public String lpFile;

        /// <summary>
        /// Address of a null-terminated string that contains the application parameters.
        /// </summary>
        [MarshalAs(UnmanagedType.LPWStr)]
        public String lpParameters;

        /// <summary>
        /// Address of a null-terminated string that specifies the name of the working directory.
        /// </summary>
        [MarshalAs(UnmanagedType.LPWStr)]
        public String lpDirectory;

        /// <summary>
        /// Flags that specify how an application is to be shown when it is opened.
        /// </summary>
        public Int32 nShow;

        /// <summary>
        /// If the function succeeds, it sets this member to a value greater than 32.
        /// </summary>
        public IntPtr hInstApp;

        /// <summary>
        /// Address of an ITEMIDLIST structure to contain an item identifier list uniquely 
        /// identifying the file to execute.
        /// </summary>
        public IntPtr lpIDList;

        /// <summary>
        /// Address of a null-terminated string that specifies the name of a file class or a 
        /// globally unique identifier (GUID).
        /// </summary>
        [MarshalAs(UnmanagedType.LPWStr)]
        public String lpClass;

        /// <summary>
        /// Handle to the registry key for the file class.
        /// </summary>
        public IntPtr hkeyClass;

        /// <summary>
        /// Hot key to associate with the application.
        /// </summary>
        public UInt32 dwHotKey;

        /// <summary>
        /// Handle to the icon for the file class. OR Handle to the monitor upon which the document is to be displayed. 
        /// </summary>
        public IntPtr hIconMonitor;

        /// <summary>
        /// Handle to the newly started application.
        /// </summary>
        public IntPtr hProcess;
    }

    /// <summary>
    /// Contains information that the SHFileOperation function uses to perform file operations.
    /// </summary> 
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public struct SHFILEOPSTRUCT
    {
        public IntPtr hwnd;						// Window handle to the dialog box to display information about the 
        // status of the file operation. 
        public UInt32 wFunc;					// Value that indicates which operation to perform.
        public IntPtr pFrom;					// Address of a buffer to specify one or more source file names. 
        // These names must be fully qualified paths. Standard Microsoft® 
        // MS-DOS® wild cards, such as "*", are permitted in the file-name 
        // position. Although this member is declared as a null-terminated 
        // string, it is used as a buffer to hold multiple file names. Each 
        // file name must be terminated by a single NULL character. An	
        // additional NULL character must be appended to the end of the 
        // final name to indicate the end of pFrom. 
        public IntPtr pTo;						// Address of a buffer to contain the name of the destination file or 
        // directory. This parameter must be set to NULL if it is not used.
        // Like pFrom, the pTo member is also a double-null terminated 
        // string and is handled in much the same way. 
        public UInt16 fFlags;					// Flags that control the file operation. 
        public Int32 fAnyOperationsAborted;		// Value that receives TRUE if the user aborted any file operations
        // before they were completed, or FALSE otherwise. 
        public IntPtr hNameMappings;			// A handle to a name mapping object containing the old and new 
        // names of the renamed files. This member is used only if the 
        // fFlags member includes the FOF_WANTMAPPINGHANDLE flag.
        [MarshalAs(UnmanagedType.LPWStr)]
        public String lpszProgressTitle;		// Address of a string to use as the title of a progress dialog box.
        // This member is used only if fFlags includes the 
        // FOF_SIMPLEPROGRESS flag.
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct RECT
    {
        public Int32 left;
        public Int32 top;
        public Int32 right;
        public Int32 bottom;
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct APPBARDATA
    {
        public UInt32 cbSize;
        public IntPtr hWnd;
        public UInt32 uCallbackMessage;
        public UInt32 uEdge;
        public RECT rc;
        public Int32 lParam;
    }


};

}